# 这个暂时看不懂。
loanAmount = eval(input("请输入贷款金额: "))
numOfYears = eval(input("请输入年份: "))
annualInterestRate = eval(input("请输入年利率: "))

monthlyInterestRate = annualInterestRate/1200
monthlyPayment = loanAmount*monthlyInterestRate / (1 - (1 / (1 + monthlyInterestRate) ** (numOfYears * 12) ))

balance = loanAmount
print("月供:", int(monthlyPayment * 100) / 100.0)
print("总金额:", int(monthlyPayment * 12 * numOfYears * 100) / 100.0)

print(format("Payment#", "<15s"), format("Interest", "<15s"), format("Principal", "<15s"), format("Balance", "<15s"))
for i in range(1, numOfYears * 12 + 1):
    interest = int(monthlyInterestRate * balance * 100) / 100.0
    principal = int((monthlyPayment - interest) * 100) / 100.0
    balance = int((balance - principal) * 100) / 100.0
    print(format(i, "<15d"), format(interest, "<15.2f"), format(principal, "<15.2f"), format(balance, "<15.2f"))
